﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using Common;
using DataAcl;
using HCRS.DBACL;
using HCRS.Implementation;
using HUBS1;
using JinJiang.BookingEngine.Services;
using Jinjiang.BLL;

namespace JinJiang.BookingEngine.Web.cn
{
public class JJResvlogClass
{
    private CommonWeb _CommonClass = new CommonWeb();
    private Functions _Functions = new Functions();
    private HotelClass _HotelClass = new HotelClass();
    private QueryXml _QueryXmlClass = new QueryXml();
    private DataAccessLayer DA = new DataAccessLayer();
    public static string emailalias = ConfigurationManager.AppSettings["emailalias"].ToString();
    public static string emailfrom = ConfigurationManager.AppSettings["emailfrom"].ToString();

    public string CxlRecord(string confnum1)
    {
        string confnum = this._CommonClass.VerifySQL(confnum1);
        string errmsg = "";
        string cxlnum = "";
        StringBuilder responseHtml = new StringBuilder();
        try
        {
            DataAccessLayer _dataAccesslayer = new DataAccessLayer();
            if (_dataAccesslayer.RunSqlExists("select * from resvlog where confnum='" + confnum + "' and status='cxl'"))
            {
                return "该订单已被其他用户取消";
            }
            this.DA.addNewParameter("@Confnum", confnum);
            DataTable tableResv = this.DA.RunStoreDataTable("FGB_JJ_GetResv");
            bool scoreok = true;
            string scoreerr = "";
            string errstr = "";
            if (tableResv.Rows.Count != 0)
            {
                int propertyid = Convert.ToInt32(tableResv.Rows[0]["propertyid"].ToString());
                DateTime starttime = Convert.ToDateTime(tableResv.Rows[0]["starttime"].ToString());
                DataTable jjdt = _dataAccesslayer.GetTable("select * from jj_carduser_bookresv where confnum='" + confnum + "' and isscore=1 and isunlock=0", "dt");
                if (scoreok)
                {
                    string status;
                    this._QueryXmlClass.CxlResv(propertyid, confnum, out errmsg, out cxlnum, out status);
                }
                if (!scoreok)
                {
                    responseHtml.Append("<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">");
                    responseHtml.Append("<tr align=\"left\">");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><b>中央预订系统返回一个错误：<b><br></td>");
                    responseHtml.Append("</tr>");
                    responseHtml.Append("<tr align=\"left\">");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/warn.gif\" />积分兑换的房间必须提前一天取消！</td>");
                    responseHtml.Append("</tr>");
                    responseHtml.Append("<tr>");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><a href=\"javascript:void(0);\" onClick=\"SearchResv()\">刷新页面</a><br /></td>");
                    responseHtml.Append("</tr>");
                    responseHtml.Append("</table>");
                }
                else if (errmsg == "")
                {
                    responseHtml.Append("<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">");
                    responseHtml.Append("<tr>");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/ok.gif\" />您的预订已经取消成功！" + scoreerr + "</td>");
                    responseHtml.Append("</tr>");
                    string strsql = "update resvlog set cxlnum='" + cxlnum + "',status='cxl' where confnum='" + confnum + "'";
                    this.DA.RunSql(strsql);
                    string _userid = tableResv.Rows[0]["userid"].ToString();
                    string nights = tableResv.Rows[0]["nights"].ToString();
                    string totalmount = tableResv.Rows[0]["totalmount"].ToString();
                    if (this._HotelClass.sendFGBemail(confnum, "Cxl", emailfrom, emailalias) == "")
                    {
                        responseHtml.Append("<tr>");
                        responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/ok.gif\" />预订取消确认信已经发出，请您注意查收</td>");
                        responseHtml.Append("</tr>");
                    }
                    else
                    {
                        responseHtml.Append("<tr>");
                        responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/warn.gif\" /><font color=red>预订取消确认信发送失败！</font></td>");
                        responseHtml.Append("</tr>");
                    }
                    responseHtml.Append("</table>");
                }
                else
                {
                    responseHtml.Append("<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">");
                    responseHtml.Append("<tr align=\"left\">");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><b>中央预订系统返回一个错误：<b><br></td>");
                    responseHtml.Append("</tr>");
                    responseHtml.Append("<tr align=\"left\">");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/warn.gif\" />" + OrderClass.GetCrsError("cxlresv", "", "", "", errmsg) + "</td>");
                    responseHtml.Append("</tr>");
                    responseHtml.Append("<tr>");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><a href=\"javascript:void(0);\" onClick=\"SearchResv()\">刷新页面</a><br /></td>");
                    responseHtml.Append("</tr>");
                    responseHtml.Append("</table>");
                }
            }
            else
            {
                responseHtml.Append("<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">");
                responseHtml.Append("<tr>");
                responseHtml.Append("<td bgcolor=\"#FFFFFF\"><b>预订记录未找到：<b><br></td>");
                responseHtml.Append("</tr>");
                responseHtml.Append("<tr>");
                responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/warn.gif\" />没有找到这个预订，请与管理员联系<br></td>");
                responseHtml.Append("</tr>");
                responseHtml.Append("<tr>");
                responseHtml.Append("<td bgcolor=\"#FFFFFF\"><a href=\"javascript:void(0);\" onClick=\"SearchResv()\">刷新页面</a><br /></td>");
                responseHtml.Append("</tr>");
                responseHtml.Append("</table>");
            }
            return responseHtml.ToString();
        }
        catch (Exception eResv)
        {
            responseHtml.Append("<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">");
            responseHtml.Append("<tr>");
            responseHtml.Append("<td bgcolor=\"#FFFFFF\">" + eResv + "</td>");
            responseHtml.Append("</tr>");
            responseHtml.Append("</table>");
            return responseHtml.ToString();
        }
    }

    public string GetSearchRecord(string confnum1, string lastname, string cardnumber)
    {
        string confnum = this._CommonClass.VerifySQL(confnum1);
        StringBuilder strTable = new StringBuilder();
        StringBuilder strGuestTable = new StringBuilder();
        StringBuilder strCxlTable = new StringBuilder();
        if (confnum != "")
        {
            this.DA.ClearParameter();
            this.DA.addNewParameter("@Confnum", confnum);
            this.DA.addNewParameter("@LastName", lastname);
            this.DA.addNewParameter("@cardnumber", cardnumber);
            DataTable tableResv = this.DA.RunStoreDataTable("FGB_JJ_GetResvAll");
            if (tableResv.Rows.Count != 0)
            {
                string ccnumber;
                string statusdesc;
                int nights = 0;
                int room = 0;
                int adults = 0;
                int children = 0;
                int propertyid = Convert.ToInt32(tableResv.Rows[0]["propertyid"].ToString());
                string roomtype = tableResv.Rows[0]["roomtype"].ToString();
                string rateclass = tableResv.Rows[0]["rateclass"].ToString();
                string starttime = Convert.ToDateTime(tableResv.Rows[0]["starttime"].ToString()).ToString("yyyy-MM-dd");
                string deptime = Convert.ToDateTime(tableResv.Rows[0]["deptime"].ToString()).ToString("yyyy-MM-dd");
                string realdeptime = Convert.ToDateTime(tableResv.Rows[0]["departure"].ToString()).ToString("yyyy-MM-dd");
                realdeptime = (realdeptime == "1900-01-01") ? "NA" : realdeptime;
                string updatetime = tableResv.Rows[0]["updatetime"].ToString();
                nights = Convert.ToInt32(tableResv.Rows[0]["nights"].ToString());
                room = Convert.ToInt32(tableResv.Rows[0]["room"].ToString());
                string guestfirstname = tableResv.Rows[0]["guestfirstname"].ToString();
                string guestlastname = tableResv.Rows[0]["guestlastname"].ToString();
                string guestemail = tableResv.Rows[0]["guestemail"].ToString();
                string guestphone = tableResv.Rows[0]["guestphone"].ToString();
                string guestaddressline1 = tableResv.Rows[0]["guestaddressline1"].ToString();
                string guestaddressline2 = tableResv.Rows[0]["guestaddressline2"].ToString();
                string guestcity = tableResv.Rows[0]["guestcity"].ToString();
                string guestcountry = tableResv.Rows[0]["guestcountry"].ToString();
                string gueststate = tableResv.Rows[0]["gueststate"].ToString();
                string guestzip = tableResv.Rows[0]["guestzip"].ToString();
                string cctype = tableResv.Rows[0]["cctype"].ToString();
                if (tableResv.Rows[0]["ccnumber"].ToString() != "")
                {
                    ccnumber = CCEncrypt.Decrypto(tableResv.Rows[0]["ccnumber"].ToString());
                }
                else
                {
                    ccnumber = "";
                }
                string ccname = tableResv.Rows[0]["ccname"].ToString();
                string ccexpyear = tableResv.Rows[0]["ccexpyear"].ToString();
                string ccexpmonth = tableResv.Rows[0]["ccexpmonth"].ToString();
                string frequentguestid = tableResv.Rows[0]["frequentguestid"].ToString();
                string iata = tableResv.Rows[0]["iata"].ToString();
                string jjremarks = "";
                string verifycode = tableResv.Rows[0]["verifycode"].ToString();
                string payment = tableResv.Rows[0]["payment"].ToString();
                DataTable jjdt = CommonDataAccess.GetTable("select Remark, isscore from  jj_carduser_bookresv where verifycode='" + verifycode + "'", "");
                string remarks = tableResv.Rows[0]["remarks"].ToString();
                if (jjremarks != "")
                {
                    remarks = remarks.Replace(jjremarks, "");
                }
                string cxlnum = tableResv.Rows[0]["cxlnum"].ToString();
                string status = tableResv.Rows[0]["status"].ToString();
                string type = "New";
                if (status == "New")
                {
                    statusdesc = "新预订";
                    type = "New";
                }
                else if (status == "mod")
                {
                    statusdesc = "修改过的预订";
                    type = "Mod";
                }
                else if (status == "cxl")
                {
                    statusdesc = "预订已取消：取消号码" + cxlnum;
                    type = "Cxl";
                }
                else
                {
                    statusdesc = "NA";
                }
                int getstatus = Convert.ToInt32(tableResv.Rows[0]["getstatus"].ToString());
                string propertyname = tableResv.Rows[0]["propertyname"].ToString();
                string propertyname_e = tableResv.Rows[0]["propertyname_e"].ToString();
                string totalmount = tableResv.Rows[0]["totalmount"].ToString();
                string dailyprice = tableResv.Rows[0]["dailyprice"].ToString();
                adults = Convert.ToInt32(tableResv.Rows[0]["adults"].ToString());
                children = Convert.ToInt32(tableResv.Rows[0]["children"].ToString());
                string plandesc = tableResv.Rows[0]["planDesc"].ToString();
                string roomname = tableResv.Rows[0]["roomname"].ToString();
                string roomdesc = tableResv.Rows[0]["roomdesc"].ToString();
                string canclerule = tableResv.Rows[0]["canclerule"].ToString();
                string guaranteerule = tableResv.Rows[0]["guaranteerule"].ToString();
                string taxrule = tableResv.Rows[0]["taxrule"].ToString();
                string incomingcall = tableResv.Rows[0]["incomingcall"].ToString();
                string fromurl = tableResv.Rows[0]["fromurl"].ToString();
                string SubSource = tableResv.Rows[0]["SubSource"].ToString();
                string lastuser = tableResv.Rows[0]["lastuser"].ToString();
                string lastusertype = tableResv.Rows[0]["lastusertype"].ToString();
                string title_e = tableResv.Rows[0]["propertyname_e"].ToString();
                string title = tableResv.Rows[0]["propertyname"].ToString();
                string address_e = tableResv.Rows[0]["address1_e"].ToString();
                string address = tableResv.Rows[0]["address1"].ToString();
                string phone = tableResv.Rows[0]["phone"].ToString();
                string hCheckIN = DataAcl.Common.formatCheckInOut(tableResv.Rows[0]["checkin"].ToString());
                string hCheckOUT = DataAcl.Common.formatCheckInOut(tableResv.Rows[0]["checkout"].ToString());
                strTable.Append("<div id=\"BasicInfo\"  >");
                strTable.Append("预订详细信息");
                //int iPayState = new OnlinePay().GetPayState(confnum);
                //string strPayState = "";
                //switch (iPayState)
                //{
                //    case 1:
                //        strPayState = "已支付";
                //        break;

                //    case -1:
                //        strPayState = "";
                //        break;

                //    case 0:
                //    {
                //        string payno = new ChinaPay().insertpaylog(confnum, totalmount, DateTime.Now);
                //        strPayState = "<a href=\"../pay/paybill.aspx?confnum=" + confnum + "&hidpayno=" + payno + "\">马上去支付</a>";
                //        break;
                //    }
                //}
                strTable.Append("<table width=\"98%\" border=\"0\" align=\"center\" id=\"tblBooking\"    cellpadding=\"5\" cellspacing=\"1\" bgColor=#cccccc>");
                strTable.Append("<tr><td colspan=\"2\" bgcolor=\"#FFFFFF\"><div align=\"center\"><strong>" + title + "入住详细信息</strong></div></td></tr>");
                strTable.Append("<tr bgcolor=\"#FFFFFF\"> <td width=\"50%\" bgcolor=\"#FFFFFF\">预订确认号：" + confnum + "</td> <td width=\"50%\">预订日期：" + updatetime + "</td></tr>");
                strTable.Append("<tr bgcolor=\"#FFFFFF\"> <td width=\"50%\" bgcolor=\"#FFFFFF\">" + statusdesc + "</td> <td width=\"50%\" ><input name=\"pid\" type=\"hidden\" id=\"pid\" value=" + propertyid.ToString() + "></td></tr>");
                strTable.Append("<tr ><td colspan=\"2\" bgcolor=\"#efefef\">预订信息：</td></tr>");
                strTable.Append("<tr bgcolor=\"#FFFFFF\"><td colspan=\"2\"><table width=\"95%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"4\"><tr><td width=\"15%\">酒店名称：</td><td width=\"85%\">" + title + "</td></tr>");
                strTable.Append("<tr><td>酒店地址：</td><td>" + address + "</td></tr>");
                strTable.Append("<tr><td>酒店电话：</td><td>" + phone + "</td></tr>");
                strTable.Append("<tr><td>抵达日期：</td><td>" + starttime + "</td></tr>");
                strTable.Append("<tr><td>离店日期：</td><td>" + deptime + "</td></tr>");
                strTable.Append("<tr><td>过夜天数：</td> <td>" + nights + "</td></tr>");
                strTable.Append("<tr><td>房间数：</td><td>" + room + "</td></tr>");
                strTable.Append("<tr><td>入住人数：</td><td>" + adults.ToString() + "</td></tr>");
                strTable.Append("<tr><td>入住房型：</td><td>" + roomname + "</td> </tr>");
                strTable.Append("<tr><td>房型描述：</td><td>" + roomdesc + "</td></tr>");
                strTable.Append("<tr><td>价格计划：</td><td>" + plandesc + "</td></tr>");
                strTable.Append("<tr><td>总价（CNY）：</td><td>" + totalmount + "</td></tr>");
                strTable.Append("<tr><td>价格明细：<br>（CNY）</td><td>");
                strTable.Append("<table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
                strTable.Append("<tr><td width=\"49%\">日期</td><td width=\"51%\">价格</td></tr>");
                string[] daily = tableResv.Rows[0]["dailyprice"].ToString().Split(new char[] { '|' });
                if ((daily != null) && (daily.Length > 1))
                {
                    for (int n = 1; n < daily.Length; n++)
                    {
                        string[] item = daily[n].Split(new char[] { ',' });
                        strTable.Append("<tr><td>" + item[0].ToString() + "</td><td>" + item[1].ToString() + "</td></tr>");
                    }
                }
                else
                {
                    strTable.Append("<tr><td></td><td></td></tr>");
                }
                strTable.Append("</table></td></tr></table></td></tr>");
                strTable.Append("<tr ><td colspan=\"2\" bgcolor=\"#efefef\">客人信息：</td></tr>");
                strTable.Append("<tr bgcolor=\"#FFFFFF\"> <td colspan=\"2\"><table width=\"95%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"4\">");
                strTable.Append("<tr><td width=\"15%\">客人姓名：</td><td width=\"85%\" colspan=\"3\">" + guestlastname + guestfirstname + "</td></tr>");
                strTable.Append("<tr><td>客人电话：</td><td  colspan=\"3\">" + guestphone + "</td></tr>");
                strTable.Append("<tr><td>备注：</td><td  colspan=\"3\">" + remarks + "</td></tr>");
                strTable.Append("<tr><td>客人email：</td><td  colspan=\"3\">" + guestemail + "</td> </tr>");
                strTable.Append("</table></td></tr>");
                strTable.Append("<tr><td colspan=\"2\" bgcolor=\"#efefef\">入住信息：</td></tr>");
                strTable.Append("<tr bgcolor=\"#FFFFFF\"><td colspan=\"2\"><table width=\"95%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"4\">");
                strTable.Append("<tr><td width=\"15%\">入住状态：</td>");
                strTable.Append("<td width=\"35%\">" + this._HotelClass.getStates(getstatus) + "</td>");
                strTable.Append("<td width=\"15%\">实际离店日期：</td>");
                strTable.Append("<td width=\"35%\">" + realdeptime + "</td></tr>");
                strTable.Append("</table></td></tr>");
                strTable.Append("<tr><td colspan=\"2\" bgcolor=\"#efefef\">酒店制度：</td></tr>");
                strTable.Append("<tr bgcolor=\"#FFFFFF\"><td colspan=\"2\"><table width=\"95%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"4\">");
                strTable.Append("<tr><td width=\"15%\">担保政策：</td>");
                strTable.Append("<td width=\"85%\">" + guaranteerule + "</td></tr>");
                strTable.Append("<tr><td>取消政策：</td><td>" + canclerule + "</td> </tr>");
                strTable.Append("<tr><td>税收类制度：</td><td>" + taxrule + "</td></tr>");
                strTable.Append("<tr><td>最早进房时间：</td><td>" + hCheckIN + "</td></tr>");
                strTable.Append("<tr><td>最晚退房时间：</td><td>" + hCheckOUT + "</td></tr>");
                strTable.Append("</table></td></tr></table>");
                strTable.Append("<br /><div align=\"center\">");
                if ((status != "cxl") && (payment != "PP"))
                {
                    strTable.Append("<a href=\"javascript:void(0);\" onClick=\"ShowMod()\">修改预订</a>&nbsp;&nbsp;&nbsp;&nbsp;");
                    strTable.Append("<a href=\"javascript:void(0);\" onClick=\"ShowCxl()\">取消预订</a>&nbsp;&nbsp;&nbsp;&nbsp;");
                }
                //if (iPayState != 0)
                //{
                strTable.Append("<a href=\"javascript:void(0);\" onClick=\"ReSendEmail('" + type + "');\">重发预订确认信email</a>");
                //}
                strTable.Append("</div><br /><br/><br/></div>");
                strGuestTable.Append("<div id=\"ModResvTableDiv\" style=\"display:none\">");
                strGuestTable.Append("<span class=\"font_bold\">修改预订</span>");
                strGuestTable.Append("<table width=98% border=0 cellpadding=5 align=\"center\"  cellspacing=1 bgcolor=#CCCCCC>");
                strGuestTable.Append("<tr bgColor=#ffffff align=left>");
                strGuestTable.Append("<td><table width=95% border=0 align=center cellpadding=5 cellspacing=0 >");
                strGuestTable.Append("<tr bgColor=#ffffff>");
                strGuestTable.Append("<td colspan=4 class=text_titl > 客人详细信息<br /></td>");
                strGuestTable.Append("</tr>");
                strGuestTable.Append("<tr bgColor=#ffffff>");
                strGuestTable.Append("<td colspan=4> 请输入本次预订客人的详细信息。在这个区域输入的姓名将被用作更改或取消本次预订，所以请正确输入。<br>");
                strGuestTable.Append("<table width=90% align=center>");
                strGuestTable.Append("<tr bgColor=#ffffff>");
                strGuestTable.Append(" <td width=20% > 客人姓名 <span class=STYLE1>*</span></td>");
                strGuestTable.Append("<td width=80% ><table width=492 >");
                strGuestTable.Append("<tr bgColor=#ffffff>");
                strGuestTable.Append("<td width valign=top ><input ID=LastName Width=50px MaxLength=30 type=text value=" + guestlastname + "> 姓 </td>");
                strGuestTable.Append("<td width ><input ID=FirstName Width=50px MaxLength=30 type=text value=" + guestfirstname + "></input> 名 </td>");
                strGuestTable.Append("</tr>");
                strGuestTable.Append("</table></td>");
                strGuestTable.Append("</tr>");
                strGuestTable.Append("<tr bgColor=#ffffff>");
                strGuestTable.Append("<td valign=top > 电子邮件 <span class=STYLE1>*</span></td>");
                strGuestTable.Append("<td ><input ID=GuestEmail Width=150 MaxLength=50 type=text value=" + guestemail + "></input></td>");
                strGuestTable.Append("</tr>");
                strGuestTable.Append("<tr bgColor=#ffffff>");
                strGuestTable.Append("<td valign=top >电话号码 <span class=STYLE1>*</span></td>");
                strGuestTable.Append("<td ><input ID=GuestPhone Width=150 MaxLength=50 type=text value=" + guestphone + "></input></td>");
                strGuestTable.Append("</tr>");
                strGuestTable.Append("<tr bgColor=#ffffff>");
                strGuestTable.Append("<td > 客户地址 <span class=STYLE1>*</span></td>");
                strGuestTable.Append("<td ><input ID=GuestAddressLine1 Width=250 MaxLength=50 type=text value=" + guestaddressline1 + "></input>                      </td>");
                strGuestTable.Append("</tr>");
                strGuestTable.Append("</table></td>");
                strGuestTable.Append("</tr>");
                strGuestTable.Append("</table>");
                strGuestTable.Append("<br>");
                strGuestTable.Append("<table width=95% border=0 align=center cellpadding=5 cellspacing=0>");
                strGuestTable.Append("<tr bgColor=#ffffff>");
                strGuestTable.Append("<td colspan=4 class=text_titl > 备注<br /></td>");
                strGuestTable.Append("</tr>");
                strGuestTable.Append("<tr bgColor=#ffffff>");
                strGuestTable.Append("<td><div align=center>");
                strGuestTable.Append("<textarea name=remark cols=30 rows=8 id=remark>" + remarks + "</textarea>");
                strGuestTable.Append("<input name=jjremark cols=50 rows=8 type=hidden id=jjremark value='" + jjremarks + "'>");
                strGuestTable.Append("</div>");
                strGuestTable.Append("</td></tr>");
                strGuestTable.Append("</table>");
                strGuestTable.Append("<br /><div align=center><a href=\"javascript:void(0);\" onClick=\"ModResv()\">提交修改</a>    <a href=\"javascript:void(0);\" onClick=\"SearchResv()\">返回</a></div><br /><br />");
                strGuestTable.Append("</td>");
                strGuestTable.Append("</tr>");
                strGuestTable.Append("</table>");
                strGuestTable.Append("<br/><br/></div>");
                strCxlTable.Append("<div id=\"CxlResvTableDiv\" style=\"display:none\">");
                strCxlTable.Append("<span class=\"font_bold\">取消预订</span>");
                strCxlTable.Append("<table width=98% border=0 cellpadding=5 align=\"center\"  cellspacing=1 bgcolor=#CCCCCC>");
                strCxlTable.Append("<tr bgColor=#ffffff>");
                strCxlTable.Append("<td colspan=4>符合取消规则的预订可以被取消。如果这个预订是要求保证金保证的，酒店将扣除这个预订的保证金<br>");
                strCxlTable.Append("</td>");
                strCxlTable.Append("</tr>");
                strCxlTable.Append("</table>");
                strCxlTable.Append("<br /><div align=center><a href=\"javascript:void(0);\" onClick=\"CxlResv()\">我确定要取消这个预订</a>    <a href=\"javascript:void(0);\" onClick=\"SearchResv()\">返回</a></div><br /><br />");
                strCxlTable.Append("</td>");
                strCxlTable.Append("</tr>");
                strCxlTable.Append("</table>");
                strCxlTable.Append("<br/><br/></div>");
            }
            else
            {
                strTable.Append("<div align=\"center\">预订记录未找到，请检查您输入的确认号码是否正确，如果您遗失了确认码，您可以在预订确认信上找到确认码或致电给酒店预订部来取消/修改预订。<br/><br/></div>");
            }
        }
        else
        {
            strTable.Append("<div align=\"center\">请填写预订确认码，您可以在预订确认信上找到确认码。如果您遗失了确认码，您可以在预订确认信上找到确认码或致电给酒店预订部来取消/修改预订。<br/><br/></div>");
        }
        strTable.Append(strGuestTable);
        strTable.Append(strCxlTable);
        return strTable.ToString();
    }

    public string ModRecord(string confnum1, string firstname1, string lastname1, string GuestAddressLine11, string GuestPhone1, string GuestEmail1, string remark1)
    {
        string confnum = this._CommonClass.VerifySQL(confnum1);
        string firstname = this._CommonClass.VerifySQL(firstname1);
        string lastname = this._CommonClass.VerifySQL(lastname1);
        string GuestAddressLine1 = this._CommonClass.VerifySQL(GuestAddressLine11);
        string GuestPhone = this._CommonClass.VerifySQL(GuestPhone1);
        string GuestEmail = this._CommonClass.VerifySQL(GuestEmail1);
        string remark = this._CommonClass.VerifySQL(remark1);
        StringBuilder responseHtml = new StringBuilder();
        try
        {
            this.DA.addNewParameter("@Confnum", confnum);
            DataTable tableResv = this.DA.RunStoreDataTable("FGB_JJ_GetResv");
            if (tableResv.Rows.Count != 0)
            {
                string errmsg;
                string status;
                int propertyid = Convert.ToInt32(tableResv.Rows[0]["propertyid"].ToString());
                OrderClass.modresv(new ResvModifyInfo { pid = propertyid, confnum = confnum, firstname = firstname, lastname = lastname, guestaddressline1 = GuestAddressLine1, guestphone = GuestPhone, guestemail = GuestEmail, remark = remark }, out errmsg, out status);
                if (errmsg == "")
                {
                    responseHtml.Append("<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">");
                    responseHtml.Append("<tr >");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/ok.gif\" />您的预订已经修改成功！ </td>");
                    responseHtml.Append("</tr>");
                    string[] bianliang = new string[] { "guestfirstname", "guestlastname", "guestaddressline1", "guestphone", "guestemail", "remarks", "status" };
                    string[] bianliangvalue = new string[] { firstname, lastname, GuestAddressLine1, GuestPhone, GuestEmail, remark, "mod" };
                    string strsql = " confnum='" + confnum + "'";
                    this.DA.UpdateData("resvlog", bianliang, bianliangvalue, strsql);
                    if (this._HotelClass.sendFGBemail(confnum, "Mod", emailfrom, emailalias) == "")
                    {
                        responseHtml.Append("<tr>");
                        responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/ok.gif\" />预订修改确认信已经发出，请您注意查收</td>");
                        responseHtml.Append("</tr>");
                    }
                    else
                    {
                        responseHtml.Append("<tr>");
                        responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/warn.gif\" /><font color=red>预订修改确认信发送失败！</font></td>");
                        responseHtml.Append("</tr>");
                    }
                    responseHtml.Append("<tr>");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><a href=\"javascript:void(0);\" onClick=\"SearchResv()\">刷新页面</a></td>");
                    responseHtml.Append("</tr>");
                    responseHtml.Append("</table>");
                }
                else
                {
                    responseHtml.Append("<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">");
                    responseHtml.Append("<tr align=\"left\">");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><b>中央预订系统返回一个错误：<b><br></td>");
                    responseHtml.Append("</tr>");
                    responseHtml.Append("<tr align=\"left\">");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/warn.gif\" />" + OrderClass.GetCrsError("modresv", "", "", "", errmsg) + "</td>");
                    responseHtml.Append("</tr>");
                    responseHtml.Append("<tr >");
                    responseHtml.Append("<td bgcolor=\"#FFFFFF\"><a href=\"javascript:void(0);\" onClick=\"SearchResv()\">刷新页面</a><br /></td>");
                    responseHtml.Append("</tr>");
                    responseHtml.Append("</table>");
                }
            }
            else
            {
                responseHtml.Append("<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">");
                responseHtml.Append("<tr>");
                responseHtml.Append("<td bgcolor=\"#FFFFFF\"><b>预订记录未找到：<b><br></td>");
                responseHtml.Append("</tr>");
                responseHtml.Append("<tr>");
                responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"images/warn.gif\" />没有找到这个预订，请与管理员联系<br></td>");
                responseHtml.Append("</tr>");
                responseHtml.Append("<tr>");
                responseHtml.Append("<td bgcolor=\"#FFFFFF\"><a href=\"javascript:void(0);\" onClick=\"SearchResv()\">刷新页面</a><br /></td>");
                responseHtml.Append("</tr>");
                responseHtml.Append("</table>");
            }
        }
        catch (Exception eResv)
        {
            responseHtml.Append("<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">");
            responseHtml.Append("<tr>");
            responseHtml.Append("<td bgcolor=\"#FFFFFF\">" + eResv + "</td>");
            responseHtml.Append("</tr>");
            responseHtml.Append("</table>");
            return responseHtml.ToString();
        }
        return responseHtml.ToString();
    }

    public string ReSendEmail(string confnum1, string type)
    {
        string confnum = this._CommonClass.VerifySQL(confnum1);
        type = this._CommonClass.VerifySQL(type);
        StringBuilder responseHtml = new StringBuilder();
        responseHtml.Append("<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">");
        responseHtml.Append("<tr>");
        responseHtml.Append("<td bgcolor=\"#FFFFFF\"><b>预订邮件发送信息：<b><br></td>");
        responseHtml.Append("</tr>");
        if (this._HotelClass.sendFGBemail(confnum, type, emailfrom, emailalias).Length == 0)
        {
            responseHtml.Append("<tr>");
            responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"/images/ok.gif\" />预订确认信已经发出，请您注意查收</td>");
            responseHtml.Append("</tr>");
        }
        else
        {
            responseHtml.Append("<tr>");
            responseHtml.Append("<td bgcolor=\"#FFFFFF\"><img src=\"/images/warn.gif\" /><font color=red>预订确认信发送失败！</font></td>");
            responseHtml.Append("</tr>");
        }
        responseHtml.Append("<tr>");
        responseHtml.Append("<td bgcolor=\"#FFFFFF\"><a href=\"javascript:void(0);\" onClick=\"SearchResv()\">刷新页面</a><br /></td>");
        responseHtml.Append("</tr>");
        responseHtml.Append("</table>");
        return responseHtml.ToString();
    }
}

 
}